/**
 */
package de.thwildau.tm.moses.avro.avdl.impl;

import de.thwildau.tm.moses.avro.avdl.AvdlPackage;
import de.thwildau.tm.moses.avro.avdl.BaseType;
import de.thwildau.tm.moses.avro.avdl.BaseTypeRef;
import de.thwildau.tm.moses.avro.avdl.Definitions;
import de.thwildau.tm.moses.avro.avdl.FieldType;
import de.thwildau.tm.moses.avro.avdl.ReturnType;
import de.thwildau.tm.moses.avro.avdl.UnionFieldType;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Base Type Ref</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.BaseTypeRefImpl#getType <em>Type</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.BaseTypeRefImpl#getBasicType <em>Basic Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BaseTypeRefImpl extends DefinitionsImpl implements BaseTypeRef
{
  /**
   * The cached value of the '{@link #getType() <em>Type</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected Definitions type;

  /**
   * The default value of the '{@link #getBasicType() <em>Basic Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBasicType()
   * @generated
   * @ordered
   */
  protected static final BaseType BASIC_TYPE_EDEFAULT = BaseType.INT;

  /**
   * The cached value of the '{@link #getBasicType() <em>Basic Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBasicType()
   * @generated
   * @ordered
   */
  protected BaseType basicType = BASIC_TYPE_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected BaseTypeRefImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AvdlPackage.Literals.BASE_TYPE_REF;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Definitions getType()
  {
    if (type != null && type.eIsProxy())
    {
      InternalEObject oldType = (InternalEObject)type;
      type = (Definitions)eResolveProxy(oldType);
      if (type != oldType)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, AvdlPackage.BASE_TYPE_REF__TYPE, oldType, type));
      }
    }
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Definitions basicGetType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(Definitions newType)
  {
    Definitions oldType = type;
    type = newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.BASE_TYPE_REF__TYPE, oldType, type));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BaseType getBasicType()
  {
    return basicType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBasicType(BaseType newBasicType)
  {
    BaseType oldBasicType = basicType;
    basicType = newBasicType == null ? BASIC_TYPE_EDEFAULT : newBasicType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.BASE_TYPE_REF__BASIC_TYPE, oldBasicType, basicType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AvdlPackage.BASE_TYPE_REF__TYPE:
        if (resolve) return getType();
        return basicGetType();
      case AvdlPackage.BASE_TYPE_REF__BASIC_TYPE:
        return getBasicType();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AvdlPackage.BASE_TYPE_REF__TYPE:
        setType((Definitions)newValue);
        return;
      case AvdlPackage.BASE_TYPE_REF__BASIC_TYPE:
        setBasicType((BaseType)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.BASE_TYPE_REF__TYPE:
        setType((Definitions)null);
        return;
      case AvdlPackage.BASE_TYPE_REF__BASIC_TYPE:
        setBasicType(BASIC_TYPE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.BASE_TYPE_REF__TYPE:
        return type != null;
      case AvdlPackage.BASE_TYPE_REF__BASIC_TYPE:
        return basicType != BASIC_TYPE_EDEFAULT;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
  {
    if (baseClass == ReturnType.class)
    {
      switch (derivedFeatureID)
      {
        case AvdlPackage.BASE_TYPE_REF__TYPE: return AvdlPackage.RETURN_TYPE__TYPE;
        default: return -1;
      }
    }
    if (baseClass == FieldType.class)
    {
      switch (derivedFeatureID)
      {
        default: return -1;
      }
    }
    if (baseClass == UnionFieldType.class)
    {
      switch (derivedFeatureID)
      {
        default: return -1;
      }
    }
    return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
  {
    if (baseClass == ReturnType.class)
    {
      switch (baseFeatureID)
      {
        case AvdlPackage.RETURN_TYPE__TYPE: return AvdlPackage.BASE_TYPE_REF__TYPE;
        default: return -1;
      }
    }
    if (baseClass == FieldType.class)
    {
      switch (baseFeatureID)
      {
        default: return -1;
      }
    }
    if (baseClass == UnionFieldType.class)
    {
      switch (baseFeatureID)
      {
        default: return -1;
      }
    }
    return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (basicType: ");
    result.append(basicType);
    result.append(')');
    return result.toString();
  }

} //BaseTypeRefImpl
